package com.example.asapp.advice;

import com.example.asapp.exception.AuthUnexpectException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@ControllerAdvice
@RestController
public class AdviceController {

    @ExceptionHandler(AuthUnexpectException.class)
    public ResponseEntity authException(AuthUnexpectException e) {

        ResponseEntity<ExceptionMsg> exceptionMsgResponseEntity=
                new ResponseEntity<ExceptionMsg>(
                        new ExceptionMsg("auth_need","no such auth"),HttpStatus.BAD_REQUEST);
        return exceptionMsgResponseEntity;
    }


}
